<template>
  <div class="all">
    <el-form :model="danbaiform" ref="danbaiform" class="demo-danbaiform">
      <h4>一、数据处理</h4>
      <div class="addmargin">
        <h5>1. 单摆法测重力加速度实验数据记录表 （每空2分共36分）</h5>
        <!-- 表1 单摆法测重力加速度实验数据记录表 -->
        <hot-table
        :settings="danbaiSettingsOne"
        :rowHeaders="true"
        :colHeaders="true"
        ></hot-table>
        <!--表2 单摆法测重力加速度实验数据处理表 -->
        <h5>2.单摆法测重力加速度实验数据处理表（每空1分共15分）</h5>
        <hot-table
        :settings="danbaiSettingsTwo"
        :rowHeaders="true"
        :colHeaders="true"
        ></hot-table>
        <!-- 表3.有效数处理与误差计算 -->
        <h5>3.有效数处理与误差计算（每空3分共18分）</h5>
        <hot-table
          :settings="danbaiSettingsThree"
          :rowHeaders="true"
          :colHeaders="true"
        ></hot-table>
        <!-- 单摆填空题 -->
        <h5>4.用单摆法测得实验所在地点重力加速度为：（每空8分共16分）</h5>
        <div style="width: 600px">
          <img
            style="height: 30px"
            src="https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_12.jpg"
            alt=""
          />
          <el-input
            onkeyup="value=value.replace(/[^\d.]/g,'')"
            v-model="danbaiform.G1"
            style="width: 50px"
          ></el-input>
          ±
          <el-input
            onkeyup="value=value.replace(/[^\d.]/g,'')"
            v-model="danbaiform.G2"
            style="width: 50px"
          ></el-input>
          <img
            style="height: 35px"
            src="https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_11.jpg"
            alt=""
          />
        </div>
      </div>

      <h4>二、选择题（每题5分，共15分）</h4>
      <div>1. 用单摆测定重力加速度g时，下面哪些做法可以减小误差？( )</div>
      <el-form-item>
        <el-radio-group v-model="danbaiform.xz1">
          <el-radio label="A">A. 摆线长度不宜太长，取0.1m左右为宜</el-radio
          ><br />
          <el-radio label="B"
            >B. 因为周期跟摆球质量无关，所以摆球用木球或铁球都一样</el-radio
          ><br />
          <el-radio label="C">C. 测摆长必须从悬点到摆球球心</el-radio><br />
          <el-radio label="D">D. 测周期必须用n次全振动总时间除以n-1</el-radio>
        </el-radio-group>
      </el-form-item>
      <div>2. 实验中某同学每次的测定值都比其它同学偏大，其原因可能是( )</div>
      <el-form-item>
        <el-radio-group v-model="danbaiform.xz2">
          <el-radio label="A">A. 实验室处在高山上，离海平面太高</el-radio><br />
          <el-radio label="B">B. 单摆所用的摆球太重</el-radio><br />
          <el-radio label="C"
            >C. 测出n次全振动的时间为t，误作为(n＋1)次全振动的时间进行计算 </el-radio
          ><br />
          <el-radio label="D">D. 以摆球半径和摆线之和作为摆长来计算</el-radio>
        </el-radio-group>
      </el-form-item>
      <div>3.如果测得g值偏小，不可能原因是( )</div>
      <el-form-item>
        <el-radio-group v-model="danbaiform.xz3">
          <el-radio label="A">A. 测摆线长时摆线拉得过紧</el-radio><br />
          <el-radio label="B">B. 摆线上端悬点未固定好，摆动中出现松动</el-radio
          ><br />
          <el-radio label="C">C. 计算摆长时，忘记了加小球半径</el-radio><br />
          <el-radio label="D">D. 读单摆周期时，读数偏大</el-radio>
        </el-radio-group>
      </el-form-item>
      <h4>线上资源</h4>
      <p class="addmargin">
        1）在线实验报告系统链接：
        <a style="text-decoration: none" href="http://180.76.111.200:3001/"
          >http://180.76.111.200:3001/</a
        >
      </p>
      <el-form-item>
        <el-button plain class="btn" type="primary" @click="storage('ruleForm')"
          >暂存</el-button
        >
        <el-button class="btn" type="primary" @click="onsubmit('danbaiform')"
          >提交</el-button
        >
      </el-form-item>
    </el-form>
    <!-- 暂存按钮的弹窗 -->
    <el-dialog title="提示" :visible.sync="DialogVisible" width="30%" center>
      <el-divider></el-divider>
      <div style="text-align: center">请 您 确 定 您 是 否 要 暂 存 ？</div>
      <el-divider></el-divider>
      <span slot="footer" class="dialog-footer">
        <el-button plain @click="DialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="(DialogVisible = false), storageOk()"
          >确 定</el-button
        >
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { HotTable } from "@handsontable/vue";
import { registerAllModules } from "handsontable/registry";
import "handsontable/dist/handsontable.full.css";
export default {
  components: {
    HotTable,
  },

  data() {
    return {
      // 111
      //  表1 单摆法测重力加速度实验数据记录表
      danbaiSettingsOne: {
        preventOverflow: "vertical", // 防止水平溢出表
        headerTooltips: true, // header 内容过长提示
        // 数据部分
        data: [
          // 定义行，一共有3行
          {
            conent: "l (cm) 悬线长度",
            beizhu: "精确到小数点后2位",
          },
          {
            conent: "d (cm) 小球直径",
            beizhu: "精确到小数点后2位",
          },
          {
            conent: "t(s) 30次周期摆动时间",
            beizhu: "精确到小数点后2位",
          },
        ],
        //最大列
        maxCols: 8,
        //最大行
        maxRows: 3,
        autoColumnSize: true, // 自适应列大小
        rowHeights: 30,
        // customBorders:[],//添加边框
        // 合并的列
        mergeCells: [],
        // 是否展示行表头,默认是1,2,3等数据,可以['行1','行2']进行自定义展示
        // rowHeaders: ['比例臂','电阻臂R0(Ω)','待测电阻值d4(Ω)'],
        height: "auto",
        // 设置表里的文字水平 + 垂直居中
        className: "htCenter htMiddle",
        rowHeaders: false,
        // 设置固定单元格不可修改
        cells(row, colum) {
          const cellProperties = {};
          if (row === 0 && colum === 0) {
            // cellProperties.editor = false;
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 0) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 0) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          // if (row === 3 && colum === 0) {
          //   cellProperties.readOnly = true;
          // } else {
          //   cellProperties.editor = "text";
          // }
          if (row === 0 && colum === 7) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 7) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 7) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          return cellProperties;
        },
        // 设置列
        columns: [
          // 第一列
          {
            data: "conent",
            editor: false,
            type: "text",
            width: 150
          },
          // 第二列
          {
            data: "number",
            width: 70,
            // type: "numeric",
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
          // 第三列
          {
            data: "number1",
            width: 70,
            // type: "numeric"
          },
          // 第四列
          {
            width: 70,
            // type: "numeric"
          },
          // 第五列
          {
            width: 70,
            // type: "numeric"
          },
          // 第六列
          {
            width: 70,
            // type: "numeric"
          },
          // 第七列
          {
            width: 70
          },
          // 第八列
          {
            data: "beizhu",
            width: 180
          },
        ],
        // colHeaders: false,
        // 设置表头 + 表头合并
        nestedHeaders: [
          // 第二行
          [
            {
              label: "测量项目↓ " + " " + " 测量次数→",
            },
            {
              label: "1",
            },
            {
              label: "2",
            },
            {
              label: "3",
            },
            {
              label: "4",
            },
            {
              label: "5",
            },
            {
              label: "6",
            },
            {
              label: "备注",
            }
          ]
        ],
        //自动换行
        autoWrapRow: true,
        // 设置非商业用途属性
        licenseKey: "non-commercial-and-evaluation",
        // 更新设置，暂存显示
        afterUpdateSettings() {
          const danbail1 = window.localStorage.getItem("danbail1");
          if (danbail1 !== "null") {
            // this.getData()[1][1] = danbaira1
            this.setDataAtCell(0, 1, danbail1);
          }
          const danbail2 = window.localStorage.getItem("danbail2");
          if (danbail2 !== "null") {
            this.setDataAtCell(0, 2, danbail2);
          }
          const danbail3 = window.localStorage.getItem("danbail3");
          if (danbail3 !== "null") {
            this.setDataAtCell(0, 3, danbail3);
          }
          const danbail4 = window.localStorage.getItem("danbail4");
          if (danbail4 !== "null") {
            this.setDataAtCell(0, 4, danbail4);
          }
          const danbail5 = window.localStorage.getItem("danbail5");
          if (danbail5 !== "null") {
            this.setDataAtCell(0, 5, danbail5);
          }
          const danbail6 = window.localStorage.getItem("danbail6");
          if (danbail6 !== "null") {
            this.setDataAtCell(0, 6, danbail6);
          }
          const danbaid1 = window.localStorage.getItem("danbaid1");
          if (danbaid1 !== "null") {
            this.setDataAtCell(1, 1, danbaid1);
          }
          const danbaid2 = window.localStorage.getItem("danbaid2");
          if (danbaid2 !== "null") {
            this.setDataAtCell(1, 2, danbaid2);
          }
          const danbaid3 = window.localStorage.getItem("danbaid3");
          if (danbaid3 !== "null") {
            this.setDataAtCell(1, 3, danbaid3);
          }
          const danbaid4 = window.localStorage.getItem("danbaid4");
          if (danbaid4 !== "null") {
            this.setDataAtCell(1, 4, danbaid4);
          }
          const danbaid5 = window.localStorage.getItem("danbaid5");
          if (danbaid5 !== "null") {
            this.setDataAtCell(1, 5, danbaid5);
          }
          const danbaid6 = window.localStorage.getItem("danbaid6");
          if (danbaid6 !== "null") {
            this.setDataAtCell(1, 6, danbaid6);
          }
          const danbait1 = window.localStorage.getItem("danbait1");
          if (danbait1 !== "null") {
            this.setDataAtCell(2, 1, danbait1);
          }
          const danbait2 = window.localStorage.getItem("danbait2");
          if (danbait2 !== "null") {
            this.setDataAtCell(2, 2, danbait2);
          }
          const danbait3 = window.localStorage.getItem("danbait3");
          if (danbait3 !== "null") {
            this.setDataAtCell(2, 3, danbait3);
          }
          const danbait4 = window.localStorage.getItem("danbait4");
          if (danbait4 !== "null") {
            this.setDataAtCell(2, 4, danbait4);
          }
          const danbait5 = window.localStorage.getItem("danbait5");
          if (danbait5 !== "null") {
            this.setDataAtCell(2, 5, danbait5);
          }
          const danbait6 = window.localStorage.getItem("danbait6");
          if (danbait6 !== "null") {
            this.setDataAtCell(2, 6, danbait6);
          }
        },
        //数据改变时触发此方法
        afterChange: function (changes, source) {
          const l1 = this.getData()[0][1];
          sessionStorage.setItem("danbail1", l1);
          const l2 = this.getData()[0][2];
          sessionStorage.setItem("danbail2", l2);
          const l3 = this.getData()[0][3];
          sessionStorage.setItem("danbail3", l3);
          const l4 = this.getData()[0][4];
          sessionStorage.setItem("danbail4", l4);
          const l5 = this.getData()[0][5];
          sessionStorage.setItem("danbail5", l5);
          const l6 = this.getData()[0][6];
          sessionStorage.setItem("danbail6", l6);
          const d1 = this.getData()[1][1];
          sessionStorage.setItem("danbaid1", d1);
          const d2 = this.getData()[1][2];
          sessionStorage.setItem("danbaid2", d2);
          const d3 = this.getData()[1][3];
          sessionStorage.setItem("danbaid3", d3);
          const d4 = this.getData()[1][4];
          sessionStorage.setItem("danbaid4", d4);
          const d5 = this.getData()[1][5];
          sessionStorage.setItem("danbaid5", d5);
          const d6 = this.getData()[1][6];
          sessionStorage.setItem("danbaid6", d6);
          const t1 = this.getData()[2][1];
          sessionStorage.setItem("danbait1", t1);
          const t2 = this.getData()[2][2];
          sessionStorage.setItem("danbait2", t2);
          const t3 = this.getData()[2][3];
          sessionStorage.setItem("danbait3", t3);
          const t4 = this.getData()[2][4];
          sessionStorage.setItem("danbait4", t4);
          const t5 = this.getData()[2][5];
          sessionStorage.setItem("danbait5", t5);
          const t6 = this.getData()[2][6];
          sessionStorage.setItem("danbait6", t6);
        },
      },
      // 222
      // 表2 单摆法测重力加速度实验数据处理表
      danbaiSettingsTwo: {
        preventOverflow: "vertical", // 防止水平溢出表
        headerTooltips: true, // header 内容过长提示
        // 数据部分
        data: [
          // 定义行，一共有3行
          {
            conent: "L(cm)=l+d/2摆长",
            beizhu: "cm",
            img1: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_1.jpg",
          },
          {
            conent: "T(s)=t/30振动周期",
            beizhu: "s",
            img1: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_2.jpg",
          },
          {
            conent: "平均重力加速度𝑔 ̅",
            beizhu: "保留4位有效数",
            danwei: "m/s^2",
            img1: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_4.jpg",
          },
        ],
        //最大列
        maxCols: 10,
        //最大行
        maxRows: 3,
        autoColumnSize: true, // 自适应列大小
        rowHeights: 30,
        // customBorders:[],//添加边框
        // 合并的列
        mergeCells: [
          { row: 2, col: 1, rowspan: 1, colspan: 4 },
          { row: 2, col: 5, rowspan: 1, colspan: 2 },
          { row: 2, col: 7, rowspan: 1, colspan: 2 }
        ],
        // 是否展示行表头,默认是1,2,3等数据,可以['行1','行2']进行自定义展示
        // rowHeaders: ['比例臂','电阻臂R0(Ω)','待测电阻值d4(Ω)'],
        height: "auto",
        // 设置表里的文字水平 + 垂直居中
        className: "htCenter htMiddle",
        rowHeaders: false,
        // 设置固定单元格不可修改
        cells(row, colum) {
          const cellProperties = {};
          if (row === 0 && colum === 0) {
            // cellProperties.editor = false;
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 0) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 0) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 5) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 0 && colum === 7) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 7) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 7) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 0 && colum === 9) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 9) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 9) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          return cellProperties;
        },
        // 设置列
        columns: [
          // 第一列
          {
            data: "conent",
            editor: false,
            type: "text",
            width: 130,
          },
          // 第二列
          {
            width: 60,
            // type: "numeric",
            // 设置显示格式
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
          // 第三列
          {
            width: 60,
            // type: "numeric",
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
          // 第四列
          {
            width: 60,
            // type: "numeric",
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
          // 第五列
          {
            width: 60,
            // type: "numeric",
          },
          // 第六列
          {
            data: "danwei",
            width: 60,
            // type: "numeric",
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
          // 第七列
          {
            width: 60,
            // type: "numeric",
          },
          // 第八列
          {
            data: "img1",
            renderer(instance, td, row, col, prop, value) {
              const img = document.createElement("img");

              img.src = value;

              img.addEventListener("mousedown", (event) => {
                event.preventDefault();
              });

              td.innerText = "";
              td.appendChild(img);

              return td;
            },
            // width: 100,
          },
          // 第九列
          {
            width: 60,
            // type: "numeric"
          },
          // 第十列
          {
            data: "beizhu",
            width: 110,
            type: "text"
          },
        ],
        // colHeaders: false,
        // 设置表头 + 表头合并
        nestedHeaders: [
          // 第二行
          [
            {
              label: "项目↓ " + " " + " 计算结果→",
            },
            {
              label: "1",
            },
            {
              label: "2",
            },
            {
              label: "3",
            },
            {
              label: "4",
            },
            {
              label: "5",
            },
            {
              label: "6",
            },
            {
              label: "平均值",
            },
            {
              label: "备注",
              colspan: 2,
            },
          ],
        ],
        //自动换行
        autoWrapRow: true,
        // 设置非商业用途属性
        licenseKey: "non-commercial-and-evaluation",
        // 更新设置，暂存显示
        afterUpdateSettings() {
          const danbaill1 = window.localStorage.getItem("danbaill1");
          if (danbaill1 !== "null") {
            this.setDataAtCell(0, 1, danbaill1);
          }
          const danbaill2 = window.localStorage.getItem("danbaill2");
          if (danbaill2 !== "null") {
            this.setDataAtCell(0, 2, danbaill2);
          }
          const danbaill3 = window.localStorage.getItem("danbaill3");
          if (danbaill3 !== "null") {
            this.setDataAtCell(0, 3, danbaill3);
          }
          const danbaill4 = window.localStorage.getItem("danbaill4");
          if (danbaill4 !== "null") {
            this.setDataAtCell(0, 4, danbaill4);
          }
          const danbaill5 = window.localStorage.getItem("danbaill5");
          if (danbaill5 !== "null") {
            this.setDataAtCell(0, 5, danbaill5);
          }
          const danbaill6 = window.localStorage.getItem("danbaill6");
          if (danbaill6 !== "null") {
            this.setDataAtCell(0, 6, danbaill6);
          }
          const danbaitt1 = window.localStorage.getItem("danbaitt1");
          if (danbaitt1 !== "null") {
            this.setDataAtCell(1, 1, danbaitt1);
          }
          const danbaitt2 = window.localStorage.getItem("danbaitt2");
          if (danbaitt2 !== "null") {
            this.setDataAtCell(1, 2, danbaitt2);
          }
          const danbaitt3 = window.localStorage.getItem("danbaitt3");
          if (danbaitt3 !== "null") {
            this.setDataAtCell(1, 3, danbaitt3);
          }
          const danbaitt4 = window.localStorage.getItem("danbaitt4");
          if (danbaitt4 !== "null") {
            this.setDataAtCell(1, 4, danbaitt4);
          }
          const danbaitt5 = window.localStorage.getItem("danbaitt5");
          if (danbaitt5 !== "null") {
            this.setDataAtCell(1, 5, danbaitt5);
          }
          const danbaitt6 = window.localStorage.getItem("danbaitt6");
          if (danbaitt6 !== "null") {
            this.setDataAtCell(1, 6, danbaitt6);
          }
          // 摆长长度平均值l
          const danbaiave_l = window.localStorage.getItem("danbaiave_l");
          if (danbaiave_l !== "null") {
            this.setDataAtCell(0, 8, danbaiave_l);
          }
          // 周期测量平均值t
          const danbaiave_t = window.localStorage.getItem("danbaiave_t");
          if (danbaiave_t !== "null") {
            this.setDataAtCell(1, 8, danbaiave_t);
          }
          // 平均重力加速度
          const danbaiave_g = window.localStorage.getItem("danbaiave_g");
          if (danbaiave_g !== "null") {
            this.setDataAtCell(2, 1, danbaiave_g);
          }
        },
        // 数据改变时触发此方法
        afterChange: function (changes, source) {
          // console.log(changes);//null
          // console.log(source);
          // console.log(this.getCellEditor());//获取全部的值
          // 挨个获取需要传给后端的值
          // console.log(this.getData()[1][1]);
          const ll1 = this.getData()[0][1];
          sessionStorage.setItem("danbaill1", ll1);
          const ll2 = this.getData()[0][2];
          sessionStorage.setItem("danbaill2", ll2);
          const ll3 = this.getData()[0][3];
          sessionStorage.setItem("danbaill3", ll3);
          const ll4 = this.getData()[0][4];
          sessionStorage.setItem("danbaill4", ll4);
          const ll5 = this.getData()[0][5];
          sessionStorage.setItem("danbaill5", ll5);
          const ll6 = this.getData()[0][6];
          sessionStorage.setItem("danbaill6", ll6);

          const tt1 = this.getData()[1][1];
          sessionStorage.setItem("danbaitt1", tt1);
          const tt2 = this.getData()[1][2];
          sessionStorage.setItem("danbaitt2", tt2);
          const tt3 = this.getData()[1][3];
          sessionStorage.setItem("danbaitt3", tt3);
          const tt4 = this.getData()[1][4];
          sessionStorage.setItem("danbaitt4", tt4);
          const tt5 = this.getData()[1][5];
          sessionStorage.setItem("danbaitt5", tt5);
          const tt6 = this.getData()[1][6];
          sessionStorage.setItem("danbaitt6", tt6);

          const ave_g = this.getData()[2][1];
          sessionStorage.setItem("danbaiave_g", ave_g);
          const ave_l = this.getData()[0][8];
          sessionStorage.setItem("danbaiave_l", ave_l);
          const ave_t = this.getData()[1][8];
          sessionStorage.setItem("danbaiave_t", ave_t);
        },
      },
      // 333
      // 表3 有效数处理与误差计算
      danbaiSettingsThree: {
        manualRowResize: true, // 自定义行宽
        manualColumnResize: true, // 自定义列高
        preventOverflow: "vertical", // 防止水平溢出表
        headerTooltips: true, // header 内容过长提示
        // 数据部分
        data: [
          // 定义行，一共有3行
          {
            conent: "直接测量误差计算",
            danwei: "cm",
            msg: "摆长绝对误差平均值",
            beizhu: "保留2位有效数",
            img3: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_5.jpg",
          },
          {
            conent: "s",
            danwei: "%",
            msg: "摆长相对误差",
            beizhu: "保留2位有效数",
            img3: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_6.jpg",
          },
          {
            conent: "",
            danwei: "s",
            msg: "振动周期绝对误差平均值",
            beizhu: "保留2位有效数",
            img3: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_7.jpg",
          },
          {
            conent: "",
            danwei: "%",
            msg: "振动周期相对误差",
            beizhu: "保留2位有效数",
            img3: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_8.jpg",
          },

          {
            conent: "间接测量误差计算",
            danwei: "%",
            msg: "g 的相对误差",
            beizhu: "保留2位有效数",
            img3: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_9.jpg",
          },
          {
            conent: "",
            danwei: "m/s^2",
            msg: "g 的绝对误差",
            beizhu: "保留2位有效数",
            img3: "https://liuru1.oss-cn-chengdu.aliyuncs.com/img/danbai11_16_10.jpg",
          },
        ],

        //最大列
        maxCols: 6,
        //最大行
        maxRows: 8,
        autoColumnSize: true, // 自适应列大小
        rowHeights: 30,
        // customBorders:[],//添加边框
        // 合并的列
        mergeCells: [
          { row: 0, col: 0, rowspan: 4, colspan: 1 },
          { row: 4, col: 0, rowspan: 2, colspan: 1 },
        ],
        // 是否展示行表头,默认是1,2,3等数据,可以['行1','行2']进行自定义展示
        // rowHeaders: ['比例臂','电阻臂R0(Ω)','待测电阻值d4(Ω)'],
        height: "auto",
        // 设置表里的文字水平 + 垂直居中
        className: "htCenter htMiddle",
        rowHeaders: false,
        // 设置固定单元格不可修改
        cells(row, colum) {
          const cellProperties = {};
          if (row === 0 && colum === 0) {
            // cellProperties.editor = false;
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 0 && colum === 1) {
            // cellProperties.editor = false;
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 0 && colum === 2) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }

          if (row === 0 && colum === 4) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 0 && colum === 5) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 0 && colum === 1) {
            // cellProperties.editor = false;
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 1) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 1) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 3 && colum === 1) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 4 && colum === 1) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 5 && colum === 1) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 4 && colum === 0) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }

          if (row === 1 && colum === 2) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 4) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 1 && colum === 5) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 2) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 4) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 2 && colum === 5) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 3 && colum === 2) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 3 && colum === 4) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 3 && colum === 5) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }

          if (row === 4 && colum === 2) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 4 && colum === 4) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 4 && colum === 5) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }

          if (row === 5 && colum === 2) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 5 && colum === 4) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          if (row === 5 && colum === 5) {
            cellProperties.readOnly = true;
          } else {
            cellProperties.editor = "text";
          }
          return cellProperties;
        },
        // 设置列
        columns: [
          // 第一列
          {
            data: "conent",
            editor: false,
            type: "text",
            width: 150,
          },
          // 第二列
          {
            data: "msg",
            width: 150,

            // type: "numeric",
            // 设置显示格式
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
          // 第三列
          {
            data: "img3",
            width: 230,
            renderer(instance, td, row, col, prop, value) {
              const img = document.createElement("img");

              img.src = value;

              img.addEventListener("mousedown", (event) => {
                event.preventDefault();
              });

              td.innerText = "";
              td.appendChild(img);

              return td;
            },
          },
          // 第四列
          {
            width: 70,
            // type: "numeric",
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
          // 第五列
          {
            data: "danwei",
            width: 50
          },
          // 第六列
          {
            data: "beizhu",
            width: 100
            // numericFormat: {
            //   pattern: "0.00",
            // },
          },
        ],
        // colHeaders: false,
        // 设置表头 + 表头合并
        nestedHeaders: [
          // 第二行
          [
            {
              label: "误差类别",
            },
            {
              label: "误差计算项",
            },
            {
              label: "计算公式",
            },
            {
              label: "计算结果",
            },
            {
              label: "单位",
            },

            {
              label: "备注"
            },
          ],
        ],
        //自动换行
        autoWrapRow: true,
        // 设置非商业用途属性
        licenseKey: "non-commercial-and-evaluation",
        // 更新设置，暂存显示
        afterUpdateSettings() {
          const danbaiR1 = window.localStorage.getItem("danbaiR1");
          if (danbaiR1 !== "null") {
            this.setDataAtCell(0, 3, danbaiR1);
          }
          const danbaiR2 = window.localStorage.getItem("danbaiR2");
          if (danbaiR2 !== "null") {
            this.setDataAtCell(1, 3, danbaiR2);
          }
          const danbaiR3 = window.localStorage.getItem("danbaiR3");
          if (danbaiR3 !== "null") {
            this.setDataAtCell(2, 3, danbaiR3);
          }
          const danbaiR4 = window.localStorage.getItem("danbaiR4");
          if (danbaiR4 !== "null") {
            this.setDataAtCell(3, 3, danbaiR4);
          }
          const danbaiR5 = window.localStorage.getItem("danbaiR5");
          if (danbaiR5 !== "null") {
            this.setDataAtCell(4, 3, danbaiR5);
          }
          const danbaiR6 = window.localStorage.getItem("danbaiR6");
          if (danbaiR6 !== "null") {
            this.setDataAtCell(5, 3, danbaiR6);
          }
        },
        // 数据改变时触发此方法
        afterChange: function (changes, source) {
          const R1 = this.getData()[0][3];
          sessionStorage.setItem("danbaiR1", R1);
          const R2 = this.getData()[1][3];
          sessionStorage.setItem("danbaiR2", R2);
          const R3 = this.getData()[2][3];
          sessionStorage.setItem("danbaiR3", R3);
          const R4 = this.getData()[3][3];
          sessionStorage.setItem("danbaiR4", R4);
          const R5 = this.getData()[4][3];
          sessionStorage.setItem("danbaiR5", R5);
          const R6 = this.getData()[5][3];
          sessionStorage.setItem("danbaiR6", R6);
        },
      },
      danbaiform: {
        l1: "",
        l2: "",
        l3: "",
        l4: "",
        l5: "",
        l6: "",

        ll1: "",
        ll2: "",
        ll3: "",
        ll4: "",
        ll5: "",
        ll6: "",

        d1: "",
        d2: "",
        d3: "",
        d4: "",
        d5: "",
        d6: "",

        t1: "",
        t2: "",
        t3: "",
        t4: "",
        t5: "",
        t6: "",

        tt1: "",
        tt2: "",
        tt3: "",
        tt4: "",
        tt5: "",
        tt6: "",

        R1: "",
        R2: "",
        R3: "",
        R4: "",
        R5: "",
        R6: "",

        ave_l: "",
        ave_t: "",
        ave_g: "",
        G1: "",
        G2: "",
        xz1: "",
        xz2: "",
        xz3: "",
      },
      DialogVisible: false,
    };
  },
  created() {
    this.storageCheck();
    localStorage.setItem("state2", 1);
  },
  //1 首先进入页面的时候需要监听浏览器的后退按钮，之后在操作的时候执行函数,在mounted中挂载去监听这个事件，并在methods里面添加函数，用来判断执行的条件
  mounted() {
    if (window.history && window.history.pushState) {
      history.pushState(null, null, document.URL);
      window.addEventListener("popstate", this.back, false);
    }
  },
  // 2：需要在退出页面的时候销毁这个监听事件
  // 注意必须要销毁this.back这个方法，不然会将this.back方法执行两遍
  destroyed() {
    window.removeEventListener("popstate", this.back, false);
  },
  methods: {
    back() {
      const state2 = localStorage.getItem("state2");
      // console.log(state2);
      if (state2 == 1) {
        this.$confirm(
          "检测到未保存的内容，是否在离开页面前保存？",
          "确认信息",
          {
            confirmButtonText: "暂存",
            cancelButtonText: "放弃修改",
            type: "warning",
            center: true,
          }
        )
          .then(() => {
            // this.$router.go(-1)
            // this.DialogVisible = true
            // const state2 = localStorage.getItem("state2");
            // console.log(state2);
            // this.$message({
            //   type: "success",
            //   message: "暂存成功！",
            // });
            this.BackStorage();
            if (this.$route.path !== "/home") {
              this.$router.push({ path: "/home" });
            }
            // this.$router.push("/home");
            return false;
          })
          .catch(() => {
            // const state2 = sessionStorage.getItem('state2')
            // console.log(state2)
            this.$message({
              type: "info",
              message: "已取消暂存！",
            });
            if (this.$route.path !== "/home") {
              this.$router.push({ path: "/home" });
            }
            // this.giveUp()
            return false;
          });
      } else {
        this.$router.push({ path: "/home" });
      }
    },
    // 放弃保存
    // giveUp() {
    //   window.localStorage.clear();
    //   if (this.$route.path !== "/home") {
    //     this.$router.push({ path: "/home" });
    //   }
    // },
    // 提交 + 接口按钮方法
    async onsubmit() {
      // // 验证为null
      // for (var key in this.danbaiform) {
      //   // console.log(this.danbaiform[key]);
      //   if (this.danbaiform[key] == "null") {
      //     this.$message.error("题目未做完！");
      //     return false;
      //   }
      // }
      // // 验证为空
      // for (var key in this.danbaiform) {
      //   if (!this.danbaiform[key]) {
      //     this.$message.error("题目未做完！");
      //     return false;
      //   }
      // }

      const { data: res } = await this.$http.post(
        "/api/danbainew",
        this.danbaiform
      );
      if (res.code == 200) {
        if (res.data.res1 == false) {
          this.$message.error("已提交，请勿重复操作！");
          this.$router.push("/home");
        } else {
          this.$message.success("提交成功");
          // 清除暂存的数据
          window.localStorage.clear();
          this.$router.push("/home");
        }
      }
      if (res.code == 422) {
              this.$message.error("请填完所有题目");
            }
      if (res.code == 100) {
        this.$message.error("已提交，请勿重复操作！");
      }
    },
    // 控制暂存弹窗出现
    storage() {
      // this.$refs[formName].validate((valid) => {
      //   if (valid) {
      //     this.DialogVisible = true;
      //   }
      // });
      // 验证规则
      // for (var key in this.danbaiform) {
      //   if (!this.danbaiform[key]) {
      //     this.$message.error("题目未做完！");
      //     return false;
      //   } else {
      this.DialogVisible = true;
      //     return false;
      //   }
      // }
    },
    // 暂存弹窗里面的确定按钮，实现暂存
    storageOk() {
      const l1 = sessionStorage.getItem("danbail1");
      this.danbaiform.l1 = l1;
      const l2 = sessionStorage.getItem("danbail2");
      this.danbaiform.l2 = l2;
      const l3 = sessionStorage.getItem("danbail3");
      this.danbaiform.l3 = l3;
      const l4 = sessionStorage.getItem("danbail4");
      this.danbaiform.l4 = l4;
      const l5 = sessionStorage.getItem("danbail5");
      this.danbaiform.l5 = l5;
      const l6 = sessionStorage.getItem("danbail6");
      this.danbaiform.l6 = l6;

      const ll1 = sessionStorage.getItem("danbaill1");
      this.danbaiform.ll1 = ll1;
      const ll2 = sessionStorage.getItem("danbaill2");
      this.danbaiform.ll2 = ll2;
      const ll3 = sessionStorage.getItem("danbaill3");
      this.danbaiform.ll3 = ll3;
      const ll4 = sessionStorage.getItem("danbaill4");
      this.danbaiform.ll4 = ll4;
      const ll5 = sessionStorage.getItem("danbaill5");
      this.danbaiform.ll5 = ll5;
      const ll6 = sessionStorage.getItem("danbaill6");
      this.danbaiform.ll6 = ll6;

      const t1 = sessionStorage.getItem("danbait1");
      this.danbaiform.t1 = t1;
      const t2 = sessionStorage.getItem("danbait2");
      this.danbaiform.t2 = t2;
      const t3 = sessionStorage.getItem("danbait3");
      this.danbaiform.t3 = t3;
      const t4 = sessionStorage.getItem("danbait4");
      this.danbaiform.t4 = t4;
      const t5 = sessionStorage.getItem("danbait5");
      this.danbaiform.t5 = t5;
      const t6 = sessionStorage.getItem("danbait6");
      this.danbaiform.t6 = t6;

      const tt1 = sessionStorage.getItem("danbaitt1");
      this.danbaiform.tt1 = tt1;
      const tt2 = sessionStorage.getItem("danbaitt2");
      this.danbaiform.tt2 = tt2;
      const tt3 = sessionStorage.getItem("danbaitt3");
      this.danbaiform.tt3 = tt3;
      const tt4 = sessionStorage.getItem("danbaitt4");
      this.danbaiform.tt4 = tt4;
      const tt5 = sessionStorage.getItem("danbaitt5");
      this.danbaiform.tt5 = tt5;
      const tt6 = sessionStorage.getItem("danbaitt6");
      this.danbaiform.tt6 = tt6;

      const d1 = sessionStorage.getItem("danbaid1");
      this.danbaiform.d1 = d1;
      const d2 = sessionStorage.getItem("danbaid2");
      this.danbaiform.d2 = d2;
      const d3 = sessionStorage.getItem("danbaid3");
      this.danbaiform.d3 = d3;
      const d4 = sessionStorage.getItem("danbaid4");
      this.danbaiform.d4 = d4;
      const d5 = sessionStorage.getItem("danbaid5");
      this.danbaiform.d5 = d5;
      const d6 = sessionStorage.getItem("danbaid6");
      this.danbaiform.d6 = d6;

      const R1 = sessionStorage.getItem("danbaiR1");
      this.danbaiform.R1 = R1;
      const R2 = sessionStorage.getItem("danbaiR2");
      this.danbaiform.R2 = R2;
      const R3 = sessionStorage.getItem("danbaiR3");
      this.danbaiform.R3 = R3;
      const R4 = sessionStorage.getItem("danbaiR4");
      this.danbaiform.R4 = R4;
      const R5 = sessionStorage.getItem("danbaiR5");
      this.danbaiform.R5 = R5;
      const R6 = sessionStorage.getItem("danbaiR6");
      this.danbaiform.R6 = R6;

      // const G1 = sessionStorage.getItem("danbaiG1");
      // this.danbaiform.G1 = G1;
      // const G2 = sessionStorage.getItem("danbaiG2");
      // this.danbaiform.G2 = G2;
      // const xz1 = sessionStorage.getItem("danbaixz1");
      // this.danbaiform.xz1 = xz1;
      // const xz2 = sessionStorage.getItem("danbaixz2");
      // this.danbaiform.xz2 = xz2;
      // const xz3 = sessionStorage.getItem("danbaixz3");
      // this.danbaiform.xz3 = xz3;
      const ave_l = sessionStorage.getItem("danbaiave_l");
      this.danbaiform.ave_l = ave_l;
      const ave_t = sessionStorage.getItem("danbaiave_t");
      this.danbaiform.ave_t = ave_t;
      const ave_g = sessionStorage.getItem("danbaiave_g");
      this.danbaiform.ave_g = ave_g;

      window.localStorage.setItem("danbail1", this.danbaiform.l1);
      window.localStorage.setItem("danbail2", this.danbaiform.l2);
      window.localStorage.setItem("danbail3", this.danbaiform.l3);
      window.localStorage.setItem("danbail4", this.danbaiform.l4);
      window.localStorage.setItem("danbail5", this.danbaiform.l5);
      window.localStorage.setItem("danbail6", this.danbaiform.l6);
      window.localStorage.setItem("danbaill1", this.danbaiform.ll1);
      window.localStorage.setItem("danbaill2", this.danbaiform.ll2);
      window.localStorage.setItem("danbaill3", this.danbaiform.ll3);
      window.localStorage.setItem("danbaill4", this.danbaiform.ll4);
      window.localStorage.setItem("danbaill5", this.danbaiform.ll5);
      window.localStorage.setItem("danbaill6", this.danbaiform.ll6);
      window.localStorage.setItem("danbait1", this.danbaiform.t1);
      window.localStorage.setItem("danbait2", this.danbaiform.t2);
      window.localStorage.setItem("danbait3", this.danbaiform.t3);
      window.localStorage.setItem("danbait4", this.danbaiform.t4);
      window.localStorage.setItem("danbait5", this.danbaiform.t5);
      window.localStorage.setItem("danbait6", this.danbaiform.t6);
      window.localStorage.setItem("danbaitt1", this.danbaiform.tt1);
      window.localStorage.setItem("danbaitt2", this.danbaiform.tt2);
      window.localStorage.setItem("danbaitt3", this.danbaiform.tt3);
      window.localStorage.setItem("danbaitt4", this.danbaiform.tt4);
      window.localStorage.setItem("danbaitt5", this.danbaiform.tt5);
      window.localStorage.setItem("danbaitt6", this.danbaiform.tt6);
      window.localStorage.setItem("danbaid1", this.danbaiform.d1);
      window.localStorage.setItem("danbaid2", this.danbaiform.d2);
      window.localStorage.setItem("danbaid3", this.danbaiform.d3);
      window.localStorage.setItem("danbaid4", this.danbaiform.d4);
      window.localStorage.setItem("danbaid5", this.danbaiform.d5);
      window.localStorage.setItem("danbaid6", this.danbaiform.d6);
      window.localStorage.setItem("danbaiR1", this.danbaiform.R1);
      window.localStorage.setItem("danbaiR2", this.danbaiform.R2);
      window.localStorage.setItem("danbaiR3", this.danbaiform.R3);
      window.localStorage.setItem("danbaiR4", this.danbaiform.R4);
      window.localStorage.setItem("danbaiR5", this.danbaiform.R5);
      window.localStorage.setItem("danbaiR6", this.danbaiform.R6);
      window.localStorage.setItem("danbaiG1", this.danbaiform.G1);
      window.localStorage.setItem("danbaiG2", this.danbaiform.G2);
      window.localStorage.setItem("danbaixz1", this.danbaiform.xz1);
      window.localStorage.setItem("danbaixz2", this.danbaiform.xz2);
      window.localStorage.setItem("danbaixz3", this.danbaiform.xz3);
      window.localStorage.setItem("danbaiave_l", this.danbaiform.ave_l);
      window.localStorage.setItem("danbaiave_t", this.danbaiform.ave_t);
      window.localStorage.setItem("danbaiave_g", this.danbaiform.ave_g);
      this.$message({
        message: "暂存成功！",
        type: "success",
      });
      localStorage.setItem("state2", 2);
    },
    // 存储按下浏览器返回键的暂存数据
    BackStorage() {
      const l1 = sessionStorage.getItem("danbail1");
      this.danbaiform.l1 = l1;
      const l2 = sessionStorage.getItem("danbail2");
      this.danbaiform.l2 = l2;
      const l3 = sessionStorage.getItem("danbail3");
      this.danbaiform.l3 = l3;
      const l4 = sessionStorage.getItem("danbail4");
      this.danbaiform.l4 = l4;
      const l5 = sessionStorage.getItem("danbail5");
      this.danbaiform.l5 = l5;
      const l6 = sessionStorage.getItem("danbail6");
      this.danbaiform.l6 = l6;

      const ll1 = sessionStorage.getItem("danbaill1");
      this.danbaiform.ll1 = ll1;
      const ll2 = sessionStorage.getItem("danbaill2");
      this.danbaiform.ll2 = ll2;
      const ll3 = sessionStorage.getItem("danbaill3");
      this.danbaiform.ll3 = ll3;
      const ll4 = sessionStorage.getItem("danbaill4");
      this.danbaiform.ll4 = ll4;
      const ll5 = sessionStorage.getItem("danbaill5");
      this.danbaiform.ll5 = ll5;
      const ll6 = sessionStorage.getItem("danbaill6");
      this.danbaiform.ll6 = ll6;

      const t1 = sessionStorage.getItem("danbait1");
      this.danbaiform.t1 = t1;
      const t2 = sessionStorage.getItem("danbait2");
      this.danbaiform.t2 = t2;
      const t3 = sessionStorage.getItem("danbait3");
      this.danbaiform.t3 = t3;
      const t4 = sessionStorage.getItem("danbait4");
      this.danbaiform.t4 = t4;
      const t5 = sessionStorage.getItem("danbait5");
      this.danbaiform.t5 = t5;
      const t6 = sessionStorage.getItem("danbait6");
      this.danbaiform.t6 = t6;

      const tt1 = sessionStorage.getItem("danbaitt1");
      this.danbaiform.tt1 = tt1;
      const tt2 = sessionStorage.getItem("danbaitt2");
      this.danbaiform.tt2 = tt2;
      const tt3 = sessionStorage.getItem("danbaitt3");
      this.danbaiform.tt3 = tt3;
      const tt4 = sessionStorage.getItem("danbaitt4");
      this.danbaiform.tt4 = tt4;
      const tt5 = sessionStorage.getItem("danbaitt5");
      this.danbaiform.tt5 = tt5;
      const tt6 = sessionStorage.getItem("danbaitt6");
      this.danbaiform.tt6 = tt6;

      const d1 = sessionStorage.getItem("danbaid1");
      this.danbaiform.d1 = d1;
      const d2 = sessionStorage.getItem("danbaid2");
      this.danbaiform.d2 = d2;
      const d3 = sessionStorage.getItem("danbaid3");
      this.danbaiform.d3 = d3;
      const d4 = sessionStorage.getItem("danbaid4");
      this.danbaiform.d4 = d4;
      const d5 = sessionStorage.getItem("danbaid5");
      this.danbaiform.d5 = d5;
      const d6 = sessionStorage.getItem("danbaid6");
      this.danbaiform.d6 = d6;

      const R1 = sessionStorage.getItem("danbaiR1");
      this.danbaiform.R1 = R1;
      const R2 = sessionStorage.getItem("danbaiR2");
      this.danbaiform.R2 = R2;
      const R3 = sessionStorage.getItem("danbaiR3");
      this.danbaiform.R3 = R3;
      const R4 = sessionStorage.getItem("danbaiR4");
      this.danbaiform.R4 = R4;
      const R5 = sessionStorage.getItem("danbaiR5");
      this.danbaiform.R5 = R5;
      const R6 = sessionStorage.getItem("danbaiR6");
      this.danbaiform.R6 = R6;
      const G1 = localStorage.getItem("danbaiG1");
      this.danbaiform.G1 = G1;
      const G2 = localStorage.getItem("danbaiG2");
      this.danbaiform.G2 = G2;
      const xz1 = localStorage.getItem("danbaixz1");
      this.danbaiform.xz1 = xz1;
      const xz2 = localStorage.getItem("danbaixz2");
      this.danbaiform.xz2 = xz2;
      const xz3 = localStorage.getItem("danbaixz3");
      this.danbaiform.xz3 = xz3;
      const ave_l = sessionStorage.getItem("danbaiave_l");
      this.danbaiform.ave_l = ave_l;
      const ave_t = sessionStorage.getItem("danbaiave_t");
      this.danbaiform.ave_t = ave_t;
      const ave_g = sessionStorage.getItem("danbaiave_g");
      this.danbaiform.ave_g = ave_g;

      window.localStorage.setItem("danbail1", this.danbaiform.l1);
      window.localStorage.setItem("danbail2", this.danbaiform.l2);
      window.localStorage.setItem("danbail3", this.danbaiform.l3);
      window.localStorage.setItem("danbail4", this.danbaiform.l4);
      window.localStorage.setItem("danbail5", this.danbaiform.l5);
      window.localStorage.setItem("danbail6", this.danbaiform.l6);
      window.localStorage.setItem("danbaill1", this.danbaiform.ll1);
      window.localStorage.setItem("danbaill2", this.danbaiform.ll2);
      window.localStorage.setItem("danbaill3", this.danbaiform.ll3);
      window.localStorage.setItem("danbaill4", this.danbaiform.ll4);
      window.localStorage.setItem("danbaill5", this.danbaiform.ll5);
      window.localStorage.setItem("danbaill6", this.danbaiform.ll6);
      window.localStorage.setItem("danbait1", this.danbaiform.t1);
      window.localStorage.setItem("danbait2", this.danbaiform.t2);
      window.localStorage.setItem("danbait3", this.danbaiform.t3);
      window.localStorage.setItem("danbait4", this.danbaiform.t4);
      window.localStorage.setItem("danbait5", this.danbaiform.t5);
      window.localStorage.setItem("danbait6", this.danbaiform.t6);
      window.localStorage.setItem("danbaitt1", this.danbaiform.tt1);
      window.localStorage.setItem("danbaitt2", this.danbaiform.tt2);
      window.localStorage.setItem("danbaitt3", this.danbaiform.tt3);
      window.localStorage.setItem("danbaitt4", this.danbaiform.tt4);
      window.localStorage.setItem("danbaitt5", this.danbaiform.tt5);
      window.localStorage.setItem("danbaitt6", this.danbaiform.tt6);
      window.localStorage.setItem("danbaid1", this.danbaiform.d1);
      window.localStorage.setItem("danbaid2", this.danbaiform.d2);
      window.localStorage.setItem("danbaid3", this.danbaiform.d3);
      window.localStorage.setItem("danbaid4", this.danbaiform.d4);
      window.localStorage.setItem("danbaid5", this.danbaiform.d5);
      window.localStorage.setItem("danbaid6", this.danbaiform.d6);
      window.localStorage.setItem("danbaiR1", this.danbaiform.R1);
      window.localStorage.setItem("danbaiR2", this.danbaiform.R2);
      window.localStorage.setItem("danbaiR3", this.danbaiform.R3);
      window.localStorage.setItem("danbaiR4", this.danbaiform.R4);
      window.localStorage.setItem("danbaiR5", this.danbaiform.R5);
      window.localStorage.setItem("danbaiR6", this.danbaiform.R6);
      window.localStorage.setItem("danbaiG1", this.danbaiform.G1);
      window.localStorage.setItem("danbaiG2", this.danbaiform.G2);
      window.localStorage.setItem("danbaixz1", this.danbaiform.xz1);
      window.localStorage.setItem("danbaixz2", this.danbaiform.xz2);
      window.localStorage.setItem("danbaixz3", this.danbaiform.xz3);
      // window.sessionStorage.setItem("danbaiG1", this.danbaiform.G1);
      // window.sessionStorage.setItem("danbaiG2", this.danbaiform.G2);
      // window.sessionStorage.setItem("danbaixz1", this.danbaiform.xz1);
      // window.sessionStorage.setItem("danbaixz2", this.danbaiform.xz2);
      // window.sessionStorage.setItem("danbaixz3", this.danbaiform.xz3);

      window.localStorage.setItem("danbaiave_l", this.danbaiform.ave_l);
      window.localStorage.setItem("danbaiave_t", this.danbaiform.ave_t);
      window.localStorage.setItem("danbaiave_g", this.danbaiform.ave_g);
      this.$message({
        message: "暂存成功！",
        type: "success",
      });
      // localStorage.setItem("state2", 2);
    },
    // 一进入页面就获取到获取暂存里面的数据，并且将数据赋值
    storageCheck() {
      const l1 = sessionStorage.getItem("danbail1");
      this.danbaiform.l1 = l1;
      const l2 = sessionStorage.getItem("danbail2");
      this.danbaiform.l2 = l2;
      const l3 = sessionStorage.getItem("danbail3");
      this.danbaiform.l3 = l3;
      const l4 = sessionStorage.getItem("danbail4");
      this.danbaiform.l4 = l4;
      const l5 = sessionStorage.getItem("danbail5");
      this.danbaiform.l5 = l5;
      const l6 = sessionStorage.getItem("danbail6");
      this.danbaiform.l6 = l6;

      const ll1 = sessionStorage.getItem("danbaill1");
      this.danbaiform.ll1 = ll1;
      const ll2 = sessionStorage.getItem("danbaill2");
      this.danbaiform.ll2 = ll2;
      const ll3 = sessionStorage.getItem("danbaill3");
      this.danbaiform.ll3 = ll3;
      const ll4 = sessionStorage.getItem("danbaill4");
      this.danbaiform.ll4 = ll4;
      const ll5 = sessionStorage.getItem("danbaill5");
      this.danbaiform.ll5 = ll5;
      const ll6 = sessionStorage.getItem("danbaill6");
      this.danbaiform.ll6 = ll6;

      const t1 = sessionStorage.getItem("danbait1");
      this.danbaiform.t1 = t1;
      const t2 = sessionStorage.getItem("danbait2");
      this.danbaiform.t2 = t2;
      const t3 = sessionStorage.getItem("danbait3");
      this.danbaiform.t3 = t3;
      const t4 = sessionStorage.getItem("danbait4");
      this.danbaiform.t4 = t4;
      const t5 = sessionStorage.getItem("danbait5");
      this.danbaiform.t5 = t5;
      const t6 = sessionStorage.getItem("danbait6");
      this.danbaiform.t6 = t6;

      const tt1 = sessionStorage.getItem("danbaitt1");
      this.danbaiform.tt1 = tt1;
      const tt2 = sessionStorage.getItem("danbaitt2");
      this.danbaiform.tt2 = tt2;
      const tt3 = sessionStorage.getItem("danbaitt3");
      this.danbaiform.tt3 = tt3;
      const tt4 = sessionStorage.getItem("danbaitt4");
      this.danbaiform.tt4 = tt4;
      const tt5 = sessionStorage.getItem("danbaitt5");
      this.danbaiform.tt5 = tt5;
      const tt6 = sessionStorage.getItem("danbaitt6");
      this.danbaiform.tt6 = tt6;

      const d1 = sessionStorage.getItem("danbaid1");
      this.danbaiform.d1 = d1;
      const d2 = sessionStorage.getItem("danbaid2");
      this.danbaiform.d2 = d2;
      const d3 = sessionStorage.getItem("danbaid3");
      this.danbaiform.d3 = d3;
      const d4 = sessionStorage.getItem("danbaid4");
      this.danbaiform.d4 = d4;
      const d5 = sessionStorage.getItem("danbaid5");
      this.danbaiform.d5 = d5;
      const d6 = sessionStorage.getItem("danbaid6");
      this.danbaiform.d6 = d6;

      const R1 = sessionStorage.getItem("danbaiR1");
      this.danbaiform.R1 = R1;
      const R2 = sessionStorage.getItem("danbaiR2");
      this.danbaiform.R2 = R2;
      const R3 = sessionStorage.getItem("danbaiR3");
      this.danbaiform.R3 = R3;
      const R4 = sessionStorage.getItem("danbaiR4");
      this.danbaiform.R4 = R4;
      const R5 = sessionStorage.getItem("danbaiR5");
      this.danbaiform.R5 = R5;
      const R6 = sessionStorage.getItem("danbaiR6");
      this.danbaiform.R6 = R6;
      const G1 = localStorage.getItem("danbaiG1");
      this.danbaiform.G1 = G1;
      const G2 = localStorage.getItem("danbaiG2");
      this.danbaiform.G2 = G2;
      const xz1 = localStorage.getItem("danbaixz1");
      this.danbaiform.xz1 = xz1;
      const xz2 = localStorage.getItem("danbaixz2");
      this.danbaiform.xz2 = xz2;
      const xz3 = localStorage.getItem("danbaixz3");
      this.danbaiform.xz3 = xz3;
      const ave_l = sessionStorage.getItem("danbaiave_l");
      this.danbaiform.ave_l = ave_l;
      const ave_t = sessionStorage.getItem("danbaiave_t");
      this.danbaiform.ave_t = ave_t;
      const ave_g = sessionStorage.getItem("danbaiave_g");
      this.danbaiform.ave_g = ave_g;

      window.localStorage.setItem("danbail1", this.danbaiform.l1);
      window.localStorage.setItem("danbail2", this.danbaiform.l2);
      window.localStorage.setItem("danbail3", this.danbaiform.l3);
      window.localStorage.setItem("danbail4", this.danbaiform.l4);
      window.localStorage.setItem("danbail5", this.danbaiform.l5);
      window.localStorage.setItem("danbail6", this.danbaiform.l6);
      window.localStorage.setItem("danbaill1", this.danbaiform.ll1);
      window.localStorage.setItem("danbaill2", this.danbaiform.ll2);
      window.localStorage.setItem("danbaill3", this.danbaiform.ll3);
      window.localStorage.setItem("danbaill4", this.danbaiform.ll4);
      window.localStorage.setItem("danbaill5", this.danbaiform.ll5);
      window.localStorage.setItem("danbaill6", this.danbaiform.ll6);
      window.localStorage.setItem("danbait1", this.danbaiform.t1);
      window.localStorage.setItem("danbait2", this.danbaiform.t2);
      window.localStorage.setItem("danbait3", this.danbaiform.t3);
      window.localStorage.setItem("danbait4", this.danbaiform.t4);
      window.localStorage.setItem("danbait5", this.danbaiform.t5);
      window.localStorage.setItem("danbait6", this.danbaiform.t6);
      window.localStorage.setItem("danbaitt1", this.danbaiform.tt1);
      window.localStorage.setItem("danbaitt2", this.danbaiform.tt2);
      window.localStorage.setItem("danbaitt3", this.danbaiform.tt3);
      window.localStorage.setItem("danbaitt4", this.danbaiform.tt4);
      window.localStorage.setItem("danbaitt5", this.danbaiform.tt5);
      window.localStorage.setItem("danbaitt6", this.danbaiform.tt6);
      window.localStorage.setItem("danbaid1", this.danbaiform.d1);
      window.localStorage.setItem("danbaid2", this.danbaiform.d2);
      window.localStorage.setItem("danbaid3", this.danbaiform.d3);
      window.localStorage.setItem("danbaid4", this.danbaiform.d4);
      window.localStorage.setItem("danbaid5", this.danbaiform.d5);
      window.localStorage.setItem("danbaid6", this.danbaiform.d6);
      window.localStorage.setItem("danbaiR1", this.danbaiform.R1);
      window.localStorage.setItem("danbaiR2", this.danbaiform.R2);
      window.localStorage.setItem("danbaiR3", this.danbaiform.R3);
      window.localStorage.setItem("danbaiR4", this.danbaiform.R4);
      window.localStorage.setItem("danbaiR5", this.danbaiform.R5);
      window.localStorage.setItem("danbaiR6", this.danbaiform.R6);
      window.localStorage.setItem("danbaiG1", this.danbaiform.G1);
      window.localStorage.setItem("danbaiG2", this.danbaiform.G2);
       window.localStorage.setItem("danbaixz1", this.danbaiform.xz1);
      window.localStorage.setItem("danbaixz2", this.danbaiform.xz2);
      window.localStorage.setItem("danbaixz3", this.danbaiform.xz3);

      window.sessionStorage.setItem("danbaiG1", this.danbaiform.G1);
      window.sessionStorage.setItem("danbaiG2", this.danbaiform.G2);
      window.sessionStorage.setItem("danbaixz1", this.danbaiform.xz1);
      window.sessionStorage.setItem("danbaixz2", this.danbaiform.xz2);
      window.sessionStorage.setItem("danbaixz3", this.danbaiform.xz3);

      window.localStorage.setItem("danbaiave_l", this.danbaiform.ave_l);
      window.localStorage.setItem("danbaiave_t", this.danbaiform.ave_t);
      window.localStorage.setItem("danbaiave_g", this.danbaiform.ave_g);
      // console.log(this.danbaiform);
      for (var key in this.danbaiform) {
        // console.log(this.danbaiform[key]);
        if (this.danbaiform[key] == "null") {
          this.danbaiform[key] = "";
          // return false;
        }
      }
    },
  },
};
</script>

<style scoped>
img {
  height: 30px;
}
.nolboder {
  border-left: 0px solid;
}
.norboder {
  border-right: 0px solid;
}
.notboder {
  border-top: 0px solid;
}
.nobboder {
  border-bottom: 0px solid;
}
.addmargin {
  margin: 10px 0px;
}
textarea {
  width: 100%;
  height: 200px;
}
.table input {
  border: none;
  outline: none;
}
.average_dcm {
  position: absolute;
  width: 160px;
  top: 35px;
  left: 330px;
  height: 125px;
}
table {
  position: relative;
  width: 500px;
}
table,
td,
th {
  border: 0.2px solid rgb(15, 15, 15);
}
.all {
  height: 100%;
  width: 50%;
  min-width: 320px;
  margin: 0 auto;
}

.btn {
  /* width: 20%;
  margin-left: 40%;
  margin-bottom: 2vw; */
  left: 0%;
  margin-bottom: 5%;
  bottom: 0%;
  width: 20%;
  transform: translate(120%, 30%);
}
.el-radio-group {
  margin: 10px;
}
.el-radio {
  padding: 5px;
}
</style>
